﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace SimpleReminder
{
    public class EventOnce : EventBase
    {
        //public EventOnce()
        //    : base()
        //{
        //    base.Type = MyEvents.EventType.Once;
        //}

        public EventOnce(DataRow dr) : base(dr)
        {
            if (base.Type != MyEvents.EventTypes.Once)
                throw new MyEvents.InvalidEventTypeException();
        }

        public override bool IsTimeToRun()
        {
            DateTime now = DateTime.Now;
            if (base.CanRun &&
                StartDate.Date <= now.Date &&
                StartDate.Hour == now.Hour &&
                StartDate.Minute == now.Minute
                )
                return true;
            return false;
        }

        public override void Run()
        {
            base.Run();
            base.Status = MyEvents.EventStatus.Completed;
        }
    }
}
